/**
 * @param {string[]} strs
 * @return {string[][]}
 */
var groupAnagrams = function(strs) {
    // 利用排序后，相同的字母异位词排序后是相同的
    let map = new Map()
    for (let i = 0; i < strs.length; i++) {
     let array = Array.from(strs[i])
     array.sort()
     let key = array.join('')
     if (map.has(key)) {
      map.get(key).push(strs[i])
     } else {
      map.set(key, [strs[i]])
     }
    }
    return Array.from(map.values())
};


let res = groupAnagrams(["eat", "tea", "tan", "ate", "nat", "bat"])
console.log(res)